package com.skivingcloud.report.service.impl;

import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.skivingcloud.report.entity.ReportDocTplCharts;
import com.skivingcloud.report.mapper.ReportDocTplChartsMapper;
import com.skivingcloud.report.service.ReportDocTplChartsService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.skivingcloud.common.utils.PageParameter;

/**
 * 文档图表信息 服务层实现。
 *
 * @author skivingcloud
 * @since 2024-11-07
 */
@Service
public class ReportDocTplChartsServiceImpl extends ServiceImpl<ReportDocTplChartsMapper, ReportDocTplCharts> implements ReportDocTplChartsService {

    /**
     * 分页查询文档图表信息
     *
     * @param parameter 查询参数
     * @return 分页查询结果
     */
    @Override
    public Page<ReportDocTplCharts> queryByPage(PageParameter<ReportDocTplCharts> parameter){
        Page<ReportDocTplCharts> page = new Page<>(parameter.getPage(), parameter.getPageSize());
        QueryWrapper queryWrapper = QueryWrapper.create();
        if (parameter.getParam() != null) {
            //查询条件
            if (StringUtils.isNoneBlank(parameter.getParam().getId())) {
                queryWrapper.and(ReportDocTplCharts::getId).like(parameter.getParam().getId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getTplId())) {
                queryWrapper.and(ReportDocTplCharts::getTplId).like(parameter.getParam().getTplId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getChartUrl())) {
                queryWrapper.and(ReportDocTplCharts::getChartUrl).like(parameter.getParam().getChartUrl());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getChartName())) {
                queryWrapper.and(ReportDocTplCharts::getChartName).like(parameter.getParam().getChartName());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getShowChartName())) {
                queryWrapper.and(ReportDocTplCharts::getShowChartName).like(parameter.getParam().getShowChartName());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getDatasetId())) {
                queryWrapper.and(ReportDocTplCharts::getDatasetId).like(parameter.getParam().getDatasetId());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getDatasetName())) {
                queryWrapper.and(ReportDocTplCharts::getDatasetName).like(parameter.getParam().getDatasetName());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getCategoryField())) {
                queryWrapper.and(ReportDocTplCharts::getCategoryField).like(parameter.getParam().getCategoryField());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getValueField())) {
                queryWrapper.and(ReportDocTplCharts::getValueField).like(parameter.getParam().getValueField());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getSeriesField())) {
                queryWrapper.and(ReportDocTplCharts::getSeriesField).like(parameter.getParam().getSeriesField());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getChartType())) {
                queryWrapper.and(ReportDocTplCharts::getChartType).like(parameter.getParam().getChartType());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getCreator())) {
                queryWrapper.and(ReportDocTplCharts::getCreator).like(parameter.getParam().getCreator());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getUpdater())) {
                queryWrapper.and(ReportDocTplCharts::getUpdater).like(parameter.getParam().getUpdater());
            }
            if (StringUtils.isNoneBlank(parameter.getParam().getDelFlag())) {
                queryWrapper.and(ReportDocTplCharts::getDelFlag).like(parameter.getParam().getDelFlag());
            }
        }
        return this.page(page, queryWrapper);
    }
}
